ml-peak-shape-generator
Peak shape generator, the current kind of shapes supported are:
Name | Equation |
---|
Gaussian | |
Lorentzian | |
Pseudo Voigt | |
where
Installation
$ npm i ml-peak-shape-generator
Usage
import { gaussian, lorentzian, pseudoVoigt} from 'ml-peak-shape-generator';
let {data, fwhm} = gaussian({factor: 3.5, sd: 500});
let {data, fwhm} = gaussian({factor: 3.5, fwhm: 500});
let {data, fwhm} = loretzian({factor: 5, fwhm: 500});
let {data, fwhm} = pseudoVoigt({{factor: 5, fwhm: 500}});
import { getShape, GAUSSIAN, LORENTZIAN, PSEUDO_VOIGT} from 'ml-peak-shape-generator';
let {data, fwhm} = getShape(LORENTZIAN, {factor: 3.5, sd: 500});
It is also possible to get a function that allows to calculate y for any x
import { gaussianFct} from 'ml-peak-shape-generator';
const func = gaussianFct({ x: 0, y: 2, width: 0.2 });
You can create a class as well and add many peaks
const peakShapeGenerator = new PeakShapeGenerator({cacheSize:20});
let shape = peakShapeGenerator.getShape(GAUSSIAN, { fwhm: 500 });
let shape2 = peakShapeGenerator.getShape(GAUSSIAN, { fwhm: 500 });
let shape3 = peakShapeGenerator.getShape(GAUSSIAN, { fwhm: 100 });
let shape4 = peakShapeGenerator.getShape(GAUSSIAN, { fwhm: 100 });
License
MIT